<HTML>
<HEAD>
<TITLE>[Chapter 20] DataFlavor </TITLE>
<META NAME="author" CONTENT="John Zukowski">
<META NAME="date" CONTENT="Thu Jul 31 15:18:59 1997">
<META NAME="form" CONTENT="html">
<META NAME="metadata" CONTENT="dublincore.0.1">
<META NAME="objecttype" CONTENT="book part">
<META NAME="otheragent" CONTENT="gmat dbtohtml">
<META NAME="publisher" CONTENT="O'Reilly &amp; Associates, Inc.">
<META NAME="source" CONTENT="SGML">
<META NAME="subject" CONTENT="Java AWT">
<META NAME="title" CONTENT="Java AWT">
<META HTTP-EQUIV="Content-Script-Type" CONTENT="text/javascript">
</HEAD>
<body vlink="#551a8b" alink="#ff0000" text="#000000" bgcolor="#FFFFFF" link="#0000ee">

<DIV CLASS=htmlnav>
<H1><a href='index.htm'><IMG SRC="gifs/smbanner.gif"
     ALT="Java AWT" border=0></a></H1>
<table width=515 border=0 cellpadding=0 cellspacing=0>
<tr>
<td width=172 align=left valign=top><A HREF="ch20_02.htm"><IMG SRC="gifs/txtpreva.gif" ALT="Previous" border=0></A></td>
<td width=171 align=center valign=top><B><FONT FACE="ARIEL,HELVETICA,HELV,SANSERIF" SIZE="-1">Chapter 20<br>java.awt.datatransfer Reference</FONT></B></TD>
<td width=172 align=right valign=top><A HREF="ch20_04.htm"><IMG SRC="gifs/txtnexta.gif" ALT="Next" border=0></A></td>
</tr>
</table>

&nbsp;
<hr align=left width=515>
</DIV>
<DIV CLASS=refnamediv>
<H1>DataFlavor <img src="gifs/bstar.gif" alt="(New)" border=0></H1>

<H2>Name</H2>

DataFlavor <img src="gifs/bstar.gif" alt="(New)" border=0>

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="ch20-REFSECT1-AUTOID.13"></A></h2>
</DIV>


<p>
<img align=middle src="./figs/datafla.gif" alt="[Graphic: Figure from the text]" width=502 height=52 border=0>

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="ch20-REFSECT1-AUTOID.14">Description</A></h2>

<P CLASS=para>
The <tt CLASS=literal>DataFlavor</tt> class encapsulates information about data formats. 

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="ch20-REFSECT1-AUTOID.15">Class Definition</A></h2>

<DIV CLASS=screen>
<P>
<PRE>
public class java.awt.datatransfer.DataFlavor
   extends java.lang.Object {
  // Class Variables
  public static DataFlavor plainTextFlavor;
  public static DataFlavor stringFlavor;
  // Constructors
  public DataFlavor (Class representationClass, 
    String humanPresentableName);
  public DataFlavor (String MIMEType, String humanPresentableName);
  // Instance Methods
  public boolean equals (DataFlavor dataFlavor);
  public String getHumanPresentableName();
  public String getMIMEType();
  public Class getRepresentationClass();
  public boolean isMIMETypeEqual (String MIMEType);
  public final boolean isMIMETypeEqual (DataFlavor dataFlavor);
  public void setHumanPresentableName (String humanPresentableName);
  // Protected Instance Methods
  protected String normalizeMIMEType (String MIMEType);
  protected String normalizeMIMETypeParameter (String parameterName, 
    String parameterValue);
}
</PRE>
</DIV>

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="ch20-REFSECT1-AUTOID.16">Class Variables</A></h2>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch20-REFSECT2-AUTOID.8">plainTextFlavor</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch20-REFSECT3-AUTOID.8">public static DataFlavor plainTextFlavor</A></h4>

<P CLASS=para>
A preset <tt CLASS=literal>DataFlavor</tt> object representing plain text.

</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch20-REFSECT2-AUTOID.9">stringFlavor</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch20-REFSECT3-AUTOID.9">public static DataFlavor stringFlavor</A></h4>

<P CLASS=para>
A preset <tt CLASS=literal>DataFlavor</tt> object 
representing a Java <tt CLASS=literal>String</tt>. 

</DIV>

</DIV>

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="ch20-REFSECT1-AUTOID.17">Constructors</A></h2>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch20-REFSECT2-AUTOID.10">DataFlavor</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch20-REFSECT3-AUTOID.10">public DataFlavor (Class representationClass, String humanPresentableName)</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><I CLASS=emphasis>representationClass</I><br>
<DD>

<P CLASS=para>
The 
Java class that represents data in this flavor.

<p>
<DT CLASS=varlistentry><I CLASS=emphasis>humanPresentableName</I><br>
<DD>

<P CLASS=para>
A 
name for this flavor that humans will recognize. </DL>
<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
Constructs a <tt CLASS=literal>DataFlavor</tt> object 
with the given characteristics. The MIME type for this <tt CLASS=literal>DataFlavor</tt> 
is <tt CLASS=literal>application/x-java-serialized-object 
&lt;Java ClassName&gt;</tt>.[1] 

<blockquote class=footnote>
<P CLASS=para>[1] 
The type name changed to <tt CLASS=literal>x-java-serialized-object</tt> in the 1.1.1 release.
</blockquote>
</DL>
</DIV>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch20-REFSECT3-AUTOID.11">public DataFlavor (String MIMEType, String humanPresentableName)</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><I CLASS=emphasis>MIMEType</I><br>
<DD>

<P CLASS=para>
The MIME type string this <tt CLASS=literal>DataFlavor</tt> 
represents.

<p>
<DT CLASS=varlistentry><I CLASS=emphasis>humanPresentableName</I><br>
<DD>

<P CLASS=para>
A 
name for this flavor that humans will recognize. </DL>
<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
Constructs a <tt CLASS=literal>DataFlavor</tt> object 
with the given characteristics. The representation class used 
for this <tt CLASS=literal>DataFlavor</tt> is <tt CLASS=literal>java.io.InputStream</tt>. </DL>
</DIV>

</DIV>

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="ch20-REFSECT1-AUTOID.18">Instance Methods</A></h2>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch20-REFSECT2-AUTOID.11">equals</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch20-REFSECT3-AUTOID.12">public boolean equals (DataFlavor dataFlavor)</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><I CLASS=emphasis>dataFlavor</I><br>
<DD>

<P CLASS=para>
The flavor to 
compare. </DL>
<p>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>true</tt> if <tt CLASS=literal>dataFlavor</tt> 
is equivalent to this <tt CLASS=literal>DataFlavor</tt>, 
<tt CLASS=literal>false</tt> otherwise. 

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
Compares two different <tt CLASS=literal>DataFlavor</tt> 
instances for equivalence. </DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch20-REFSECT2-AUTOID.12">getHumanPresentableName</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch20-REFSECT3-AUTOID.13">public String getHumanPresentableName()</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
The name of this flavor. </DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch20-REFSECT2-AUTOID.13">getMIMEType</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch20-REFSECT3-AUTOID.14">public String getMIMEType()</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
The MIME type string for this flavor. </DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch20-REFSECT2-AUTOID.14">getRepresentationClass</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch20-REFSECT3-AUTOID.15">public Class getRepresentationClass()</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
The Java class that will be used to represent data in this flavor. </DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch20-REFSECT2-AUTOID.15">isMIMETypeEqual</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch20-REFSECT3-AUTOID.16">public boolean isMIMETypeEqual (String MIMEType)</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><I CLASS=emphasis>MIMEType</I><br>
<DD>

<P CLASS=para>
The type to compare. </DL>
<p>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>true</tt> if the given MIME type 
is the same as this <tt CLASS=literal>DataFlavor</tt>'s 
MIME type; <tt CLASS=literal>false</tt> otherwise. 

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
Compares two different <tt CLASS=literal>DataFlavor</tt> 
MIME types for equivalence. </DL>
</DIV>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch20-REFSECT3-AUTOID.17">public final boolean isMIMETypeEqual (DataFlavor dataFlavor)</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><I CLASS=emphasis>dataFlavor</I><br>
<DD>

<P CLASS=para>
The flavor to 
compare. </DL>
<p>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>true</tt> if <tt CLASS=literal>DataFlavor</tt>'s 
MIME type is the same as this <tt CLASS=literal>DataFlavor</tt>'s 
MIME type; <tt CLASS=literal>false</tt> otherwise. 

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
Compares two different <tt CLASS=literal>DataFlavor</tt> 
MIME types for equivalence. </DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch20-REFSECT2-AUTOID.16">setHumanPresentableName</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch20-REFSECT3-AUTOID.18">public void setHumanPresentableName (String humanPresentableName)</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><I CLASS=emphasis>humanPresentableName</I><br>
<DD>

<P CLASS=para>
A 
name for this flavor that humans will recognize. </DL>
<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
Changes the name of the <tt CLASS=literal>DataFlavor</tt>. </DL>
</DIV>

</DIV>

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="ch20-REFSECT1-AUTOID.19">Protected Instance Methods</A></h2>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch20-REFSECT2-AUTOID.17">normalizeMIMEType</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch20-REFSECT3-AUTOID.19">protected String normalizeMIMEType (String MIMEType)</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><I CLASS=emphasis>MIMEType</I><br>
<DD>

<P CLASS=para>
The 
MIME type string to normalize. </DL>
<p>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
Normalized MIME type string. 

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method is called for each MIME type string. Subclasses can override 
this method to add default parameter/value pairs to MIME strings. </DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch20-REFSECT2-AUTOID.18">normalizeMIMETypeParameter</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch20-REFSECT3-AUTOID.20">protected String normalizeMIMETypeParameter (String parameterName, String parameterValue)</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><I CLASS=emphasis>parameterName</I><br>
<DD>

<P CLASS=para>
The MIME type parameter to normalize.

<p>
<DT CLASS=varlistentry><I CLASS=emphasis>parameterValue</I><br>
<DD>

<P CLASS=para>
The corresponding value. </DL>
<p>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
Normalized MIME type parameter string. 

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method is called for each MIME type parameter string. Subclasses can 
override this method to handle special parameters, such as those that are 
case-insensitive. </DL>
</DIV>

</DIV>

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="ch20-REFSECT1-AUTOID.20">See Also</A></h2>

<P CLASS=para>
<tt CLASS=literal>Class</tt>, <tt CLASS=literal>String</tt> 

</DIV>


<DIV CLASS=htmlnav>

<P>
<HR align=left width=515>
<table width=515 border=0 cellpadding=0 cellspacing=0>
<tr>
<td width=172 align=left valign=top><A HREF="ch20_02.htm"><IMG SRC="gifs/txtpreva.gif" ALT="Previous" border=0></A></td>
<td width=171 align=center valign=top><a href="index.htm"><img src='gifs/txthome.gif' border=0 alt='Home'></a></td>
<td width=172 align=right valign=top><A HREF="ch20_04.htm"><IMG SRC="gifs/txtnexta.gif" ALT="Next" border=0></A></td>
</tr>
<tr>
<td width=172 align=left valign=top>ClipboardOwner <img src="gifs/bstar.gif" alt="(New)" border=0></td>
<td width=171 align=center valign=top><a href="index/idx_a.htm"><img src='gifs/index.gif' alt='Book Index' border=0></a></td>
<td width=172 align=right valign=top>StringSelection <img src="gifs/bstar.gif" alt="(New)" border=0></td>
</tr>
</table>
<hr align=left width=515>

<IMG SRC="gifs/smnavbar.gif" USEMAP="#map" BORDER=0> 
<MAP NAME="map"> 
<AREA SHAPE=RECT COORDS="0,0,108,15" HREF="../javanut/index.htm"
alt="Java in a Nutshell"> 
<AREA SHAPE=RECT COORDS="109,0,200,15" HREF="../langref/index.htm" 
alt="Java Language Reference"> 
<AREA SHAPE=RECT COORDS="203,0,290,15" HREF="../awt/index.htm" 
alt="Java AWT"> 
<AREA SHAPE=RECT COORDS="291,0,419,15" HREF="../fclass/index.htm" 
alt="Java Fundamental Classes"> 
<AREA SHAPE=RECT COORDS="421,0,514,15" HREF="../exp/index.htm" 
alt="Exploring Java"> 
</MAP>
</DIV>

</BODY>
</HTML>
